﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;
using System.Configuration;
using Tamir.SharpSsh;
using Tamir.SharpSsh.jsch;

namespace HoneyBadgersOfficePlayer.Models
{
    public partial class SCPUtilities
    {
        public static void Upload(string filename, string path)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("EnableSCP")))
            {
                string host = ConfigurationManager.AppSettings.Get("SCPDirectory");
                string user = ConfigurationManager.AppSettings.Get("SCPLogin");
                string password = ConfigurationManager.AppSettings.Get("SCPPassword");
                string newDirectory = "/home/honeybadgers/public_html/Music Files/" + Globals.UserID + "/";

                //Create a new SCP instance
                Scp scp = new Scp(host, user, password);
                
                scp.Connect();
                scp.Mkdir(newDirectory);

                //Copy a file from local machine to remote SSH server
                scp.To(path, newDirectory + filename);
            }
        }
    }
}
